﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.Pipes;


namespace StreamClient
{
    class Program
    {
        static void Main(string[] args)
        {
            int start = Environment.TickCount;
            int acum = 0;

            using (NamedPipeClientStream npcs =
                new NamedPipeClientStream(
                    ".",  
                    //"\\\\sm-ftp\\",
                    "testpipe", PipeDirection.In))
            {
                npcs.Connect();

                using (StreamReader sr = new StreamReader(npcs))
                { 
                    string linea = "";

                    while ((linea = sr.ReadLine()) != null)
                    {
                        acum += linea.Length;

                        if ((Environment.TickCount - start) >= 1000)
                        {
                            Console.WriteLine("{0} B/seg   {1:0.##} KB/seg   {2:0.##} MB/seg", acum, acum / 1024.0, acum / 1024.0 / 1024.0);
                            start = Environment.TickCount;
                            acum = 0;
                        }
                    }
                }
            }
        }
    }
}
